package com.tiger.cmpeb.sample1;

import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;

public abstract class CustomerBean01 implements EntityBean {

	private static final long serialVersionUID = 1L;

	private EntityContext entityContext = null;

	public abstract Integer getCustomerID();

	public abstract void setCustomerID(Integer customerID);

	public abstract String getName();

	public abstract void setName(String name);

	public abstract int getAge();

	public abstract void setAge(int age);

	public Integer ejbCreate(Integer customerID, String name, int age) throws CreateException {
		System.out.println("Called ejbCreate.");
		setCustomerID(customerID);
		setName(name);
		setAge(age);
		return customerID;
	}

	public void ejbPostCreate(Integer customerID, String name, int age) {
		System.out.println("Called ejbPostCreate.");
	}

	public String ejbHomeCheckAgeGroup(int age) {
		if (age < 20) {
			return "YOUNG AGE";
		} else if (age < 40) {
			return "ADULT AGE";
		} else if (age < 65) {
			return "MIDDLE AGE";
		} else {
			return "OLD AGE";
		}
	}

	public void ejbActivate() throws EJBException, RemoteException {

	}

	public void ejbLoad() throws EJBException, RemoteException {

	}

	public void ejbPassivate() throws EJBException, RemoteException {

	}

	public void ejbRemove() throws RemoveException, EJBException, RemoteException {

	}

	public void ejbStore() throws EJBException, RemoteException {

	}

	public void setEntityContext(EntityContext entityContext) throws EJBException, RemoteException {
		this.entityContext = entityContext;

	}

	public void unsetEntityContext() throws EJBException, RemoteException {
		this.entityContext = null;
	}

}
